dofile(arg[1])
require("lfs")
require("sputnik_config")

local dest_dir = sputnik_config.WIKI_DATA_DIR
lfs.mkdir(dest_dir)
local source_dir = "data/"

for page_name in lfs.dir(source_dir) do
   if page_name:len() > 2 and (not (page_name:sub(1,1) == ".")) then
      print(page_name)
      local f = io.open(source_dir .. page_name)
      if not f then
	 error("Can't open file " .. source_dir .. page_name)
      end
      local raw = f:read("*all")
      f:close()

      local outpath = dest_dir .. "/" .. page_name
      print(outpath)
      local x = lfs.mkdir(outpath)
      print(x)

      outpath = outpath .. "/1957-10-04 00:00:00"
      local outf = io.open(outpath, "w")
      if not outf then
         error("Can't open file for writing: " .. outpath)
      end
      outf:write(raw)
      outf:close()
   end
end

